package com.haohan.jingyuan.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * MyBatis-Plus 配置类。
 * <p>
 * 负责注册分页拦截器，并配置 Mapper 扫描路径与事务管理。
 * </p>
 */
@Configuration
@MapperScan(basePackages = "com.haohan.jingyuan.*.dao")
@EnableTransactionManagement
public class MyBatisPlusConfig {

    /**
     * 注册 MyBatis-Plus 拦截器，开启分页能力。
     *
     * @return MybatisPlusInterceptor 实例
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        return interceptor;
    }
}